<template>
    <div>
        <el-card>
            <el-form :model="formInline" label-width="70px" class="demo-form-inline">
                <el-form-item label="账号">
                    <el-input v-model="formInline.account" disabled placeholder="请输入账号" />
                </el-form-item>
                <el-form-item label="密码">
                    <span>******</span>
                    <el-button type="primary" link @click="onInfopwd">修改密码</el-button>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="formInline.name" placeholder="请输入姓名" />
                </el-form-item>
                <el-form-item label="电话">
                    <el-input v-model="formInline.phone" placeholder="请输入电话" />
                </el-form-item>
                <el-form-item label="邮箱">
                    <el-input v-model="formInline.email" placeholder="请输入邮箱" />
                </el-form-item>
                <el-form-item label="">
                    <el-button type="primary" class="submitBtn" @click="onSubmit">保存</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>
<script setup lang="ts">
import { reactive, ref } from "vue";
// import { Md5 } from 'ts-md5';
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import { userStores } from "@/stores";
import { updateUserInfo, getMyUserInfo } from "@/utils/api";
const router = useRouter();
const store = userStores();
const formInline: any = ref(store.user.userInfo);
const onSubmit = () => {
    console.log(formInline.value);
    if (!formInline.value.name) {
        ElMessage.error("姓名不能为空");
        return;
    }
    if (!formInline.value.phone) {
        ElMessage.error("电话不能为空");
        return;
    }
    updateUserInfo(formInline.value).then((res: any) => {
        ElMessage.success("修改成功");
        getMyUserInfo();
        router.back();
    });
};
const onInfopwd = () => {
    router.push("/users/infopwd");
};
</script>
<style scoped lang="scss">
.demo-form-inline {
    width: 600px;
    position: relative;
    transform: translateX(-50%);
    left: 50%;
    span {
        margin-right: 20px;
    }
}
</style>
